import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '人员需求编号',
    align: "center",
    sorter: true,
    dataIndex: 'positionReqNo',
    resizable: true //配置列可伸缩
  },
  {
    title: '项目名称',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText',
    resizable: true //配置列可伸缩
  },
  {
    title: '需求部门',
    align: "center",
    sorter: true,
    dataIndex: 'departId_dictText',
    resizable: true //配置列可伸缩
  },
  // {
  //   title: '采购需求编号',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'oaReqNo'
  // },
  {
    title: '需求岗位',
    align: "center",
    sorter: true,
    dataIndex: 'positionId_dictText',
    resizable: true //配置列可伸缩
  },
  {
    title: '岗位级别',
    align: "center",
    sorter: true,
    dataIndex: 'positionLevel_dictText',
    resizable: true, //配置列可伸缩
    customRender: ({ text }) => {
      const color = 'red';
      if(text =='A') {
        return render.renderTag(text, 'green');
      } else if(text =='B') {
        return render.renderTag(text, 'blue');
      } else if(text =='C') {
        return render.renderTag(text, 'red');
      }
    }
  },
  {
    title: '用人周期(月)',
    align: "center",
    sorter: true,
    dataIndex: 'useMonth',
    resizable: true //配置列可伸缩
  },
  {
    title: '状态',
    align: "center",
    sorter: true,
    dataIndex: 'reqStatus',
    resizable: true, //配置列可伸缩
    
    // edit: true,
    // editComponent: 'Select',
    //   editComponentProps: {
    //     options: [
    //       {
    //         label: '待发布',
    //         value: '1',
    //       },
    //       {
    //         label: '已发布',
    //         value: '2',
    //       },
    //       {
    //         label: '暂停',
    //         value: '3',
    //       },
    //       {
    //         label: '已下架',
    //         value: '4',
    //       },
    //     ],
    //   },
    filters: [
      { text: '草稿', value: '0' },
      { text: '待发布', value: '1' },
      { text: '已发布', value: '2' },
      { text: '暂停', value: '3' },
      { text: '已下架', value: '4' },
      { text: '招聘中', value: '5' },
      { text: '已完成', value: '6' },
      // dictCode: "tm_project,project_name,id"
    ],
    customRender: ({text }) => {
      if(parseInt(text) == 0) {
        // return "暂存";
        return render.renderTag('草稿', 'grey');
      } else if(parseInt(text) == 1){
        return render.renderTag('待发布', 'yellow');
      } else if(parseInt(text) == 2){
        return render.renderTag('已发布', 'green'); //green
      } else if(parseInt(text) == 3){
        return render.renderTag('暂停', 'orange');
      } else if(parseInt(text) == 4){
        return render.renderTag('已下架', 'purple');
      } else if(parseInt(text) == 5){
        return render.renderTag('招聘中', 'blue');
      } else if(parseInt(text) == 6){
        return render.renderTag('已完成', 'rgb(0, 195, 69)');
      }
    }
  },
  {
    title: '需求人数',
    align: "center",
    sorter: true,
    dataIndex: 'positionCount',
    resizable: true //配置列可伸缩
  },
  {
    title: '已入场人数',
    align: "center",
    sorter: true,
    dataIndex: 'entryProjectCount',
    resizable: true //配置列可伸缩
  },
  {
    title: '招聘对接人',
    align: "center",
    sorter: true,
    dataIndex: 'reqContract_dictText',
    resizable: true //配置列可伸缩
  },
  
  // {
  //   title: '岗位技能',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'positionSkill'
  // },


  // {
  //   title: '电话',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'reqContractMobile'
  // },
  // {
  //   title: '邮箱',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'reqContractEmail'
  // },
  // {
  //   title: '工作地点',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'workPlace_dictText'
  // },
  // {
  //   title: '工作地址',
  //   align: "center",
  //   dataIndex: 'workPlaceAddress'
  // },
  {
    title: '开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'endDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  
  {
    title: '创建人',
    align: "center",
    sorter: true,
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
];
//锁定简历列表
export const lockResumeListColumns: JVxeColumn[] = [
  {
    title: '姓名',
    key: 'realName',
    type: JVxeTypes.input,
    width:"200px",
  },
  {
    title: '性别',
    key: 'jender',
    type: JVxeTypes.select,
    dictCode:"jender",
    width:"200px",
  },
  {
    title: '性别',
    key: 'jender',
    type: JVxeTypes.select,
    dictCode:"jender",
    width:"200px",
  },
  {
    title: '学历',
    key: 'education',
    type: JVxeTypes.input,
    dictCode:"education",
    width:"200px",
  },
  {
    title: '专业',
    key: 'major',
    type: JVxeTypes.input,
    width:"200px",
  },
  {
    title: '工作年限',
    key: 'workYears',
    type: JVxeTypes.input,
    width:"200px",
  },
  {
    title: '入场状态',
    key: 'entryStatus',
    type: JVxeTypes.select,
    dictCode:"entry_status",
    width:"200px",
  },
]
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目名称",
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "需求部门",
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart where org_type='2',depart_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "采购需求编号",
    field: "oaReqNo",
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: "需求岗位",
    field: 'positionId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_position,position_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "岗位级别",
    field: 'positionLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "position_level"
    },
    //colProps: {span: 6},
  },
  {
    label: "招聘对接人",
    field: 'reqContract',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    //colProps: {span: 6},
  },
  {
    label: "电话",
    field: 'reqContractMobile',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "邮箱",
    field: 'reqContractEmail',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "工作地点",
    field: 'workPlace',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_work_place,work_place,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "开始时间",
    field: "startDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "结束时间",
    field: "endDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'reqStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "req_status"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目名称',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目名称!'},
             ];
    },
  },
  {
    label: '需求部门',
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart where org_type='2',depart_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入需求部门!'},
             ];
    },
  },
  {
    label: '采购需求编号',
    field: 'oaReqNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入采购需求编号!'},
             ];
    },
  },
  {
    label: '需求岗位',
    field: 'positionId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_position,position_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入需求岗位!'},
             ];
    },
  },
  {
    label: '岗位级别',
    field: 'positionLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "position_level"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入岗位级别!'},
             ];
    },
  },
  {
    label: '岗位技能',
    field: 'positionSkill',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入岗位技能!'},
             ];
    },
  },
  {
    label: '需求数量',
    field: 'positionCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入需求数量!'},
              { pattern: /^-?\d+$/, message: '请输入整数!'},
             ];
    },
  },
  {
    label: '招聘对接人',
    field: 'reqContract',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目负责人!'},
             ];
    },
  },
  {
    label: '电话',
    field: 'reqContractMobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入电话!'},
              { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
             ];
    },
  },
  {
    label: '邮箱',
    field: 'reqContractEmail',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入邮箱!'},
              { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
             ];
    },
  },
  {
    label: '工作地点',
    field: 'workPlace',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_work_place,work_place,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入工作地点!'},
             ];
    },
  },
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开始时间!'},
             ];
    },
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入结束时间!'},
             ];
    },
  },
  {
    label: '用人周期',
    field: 'useDays',
    component: 'InputNumber',
    dynamicDisabled: true
  },
  {
    label: '岗位职责',
    field: 'reqDesc',
    component: 'JEditor',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入岗位职责!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目名称',order: 0,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  departId: {title: '需求部门',order: 1,view: 'sel_search', type: 'string',dictTable: "sys_depart where org_type='2'", dictCode: 'id', dictText: 'depart_name',},
  oaReqNo: {title: '采购需求编号',order: 2,view: 'text', type: 'string',},
  positionId: {title: '需求岗位',order: 3,view: 'sel_search', type: 'string',dictTable: "tm_position", dictCode: 'id', dictText: 'position_name',},
  positionLevel: {title: '岗位级别',order: 4,view: 'list', type: 'string',dictCode: 'position_level',},
  positionSkill: {title: '岗位技能',order: 5,view: 'text', type: 'string',},
  positionCount: {title: '需求数量',order: 6,view: 'number', type: 'number',},
  entryProjectCount: {title: '已入场人数',order: 7,view: 'number', type: 'number',},
  reqContract: {title: '项目负责人',order: 8,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  reqContractMobile: {title: '电话',order: 9,view: 'text', type: 'string',},
  reqContractEmail: {title: '邮箱',order: 10,view: 'text', type: 'string',},
  workPlace: {title: '工作地点',order: 11,view: 'sel_search', type: 'string',dictTable: "tm_work_place", dictCode: 'id', dictText: 'work_place',},
  workPlaceAddress: {title: '工作地址',order: 12,view: 'text', type: 'string',},
  startDate: {title: '开始时间',order: 13,view: 'date', type: 'string',},
  endDate: {title: '结束时间',order: 14,view: 'date', type: 'string',},
  useDays: {title: '用人周期',order: 15,view: 'number', type: 'number',},
  reqStatus: {title: '状态',order: 16,view: 'list', type: 'string',dictCode: 'req_status',},
  createBy: {title: '创建人',order: 18,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 19,view: 'datetime', type: 'string',},
};
